<script lang="ts" setup>
import { computed, ref } from 'vue';

const firstname=ref('json')
const lastname=ref('pert')

const fullName = computed({
  get() {
    return firstname.value+' '+lastname.value
  },
  set(value) {
    const names=value.split(' ')
    firstname.value = names[0]
    lastname.value = names[1]
  }
})
</script>

<template>     
  <input type="text" v-model="firstname">
  <input type="text" v-model="lastname">
  <p>完整姓名</p>
  <input type="text" v-model="fullName">
</template>